<template>
    <div class="tour-order">
        <div class="tabs">
            <ul>
                <li class="fl" @click="queryParam.orderStatus='-1',tourListNow()" :class="{'active':queryParam.orderStatus=='-1'}">全部</li>
                <li class="fl" @click="queryParam.orderStatus='0',tourListNow()" :class="{'active':queryParam.orderStatus=='0'}">待支付</li>
                <li class="fl" @click="queryParam.orderStatus='1',tourListNow()" :class="{'active':queryParam.orderStatus=='1'}">待出行</li>
                <li class="fl" @click="queryParam.orderStatus='2',tourListNow()" :class="{'active':queryParam.orderStatus=='2'}">已完成</li>
            </ul>
        </div>
        <div class="ment">
            订单完成后24小时内有问题方可申请售后/投诉
        </div>
        <!-- <div class="line"></div> -->
        <div class="listm">
            <ul>
                <li v-for="(item,index) in list">
                    <div class="top clearfix">
                        <div class="img fl">
                            <img src="../../assets/imgs/tour/order-a.png" alt="" v-if="item.type=='onDay'">
                            <img src="../../assets/imgs/tour/order-b.png" alt="" v-if="item.type=='nearby'">
                            <img src="../../assets/imgs/tour/order-c.png" alt="" v-if="item.type=='demestic'">
                            <img src="../../assets/imgs/tour/order-d.png" alt="" v-if="item.type=='outbound'">
                            <img src="../../assets/imgs/tour/order-e.png" alt="" v-if="item.type=='localTourism'">
                            <img src="../../assets/imgs/tour/order-e.png" alt="" v-if="item.type=='islandTourism'">
                            <img src="../../assets/imgs/tour/order-e.png" alt="" v-if="item.type=='other'">
                        </div>
                            <p class="word fl" v-if="item.type=='onDay'">一日游</p>
                            <p class="word fl" v-if="item.type=='nearby'">周边游</p>
                            <p class="word fl" v-if="item.type=='demestic'">出境游</p>
                            <p class="word fl" v-if="item.type=='outbound'">当地游</p>
                            <p class="word fl" v-if="item.type=='localTourism'">当地游</p>
                            <p class="word fl" v-if="item.type=='islandTourism'">海岛游</p>
                            <p class="word fl" v-if="item.type=='other'">非团体旅游</p>
                            <p class="words fr" v-if="item.orderStatus=='finished'">订单已完成</p>
                            <p class="words fr" v-if="item.orderStatus=='canceled'">订单已取消</p>
                            <p class="words wordt fr" v-if="item.orderStatus=='paid'">待出行</p>
                            <p class="words wordt fr" v-if="item.orderStatus=='unPaid'">待支付</p>
                        </div>
                        <div class="center" @click="gotoDetalDtl(item.id)">
                            <div class="title clearfix">
                                <p class="tits fl">{{item.tourTitle}} </p>
                                <p class="state fr">
                                    <span>￥</span>
                                    <span>{{item.totalPrice}}</span>
                                </p>

                            </div>
                            <div class="time">
                                <p class="word">出发时间: {{item.startDate}} </p>
                                <p class="word">亲友数量: {{item.numOfRelatives}}人</p>
                            </div>
                        </div>
                        <div class="fott clearfix">
                            <p class="fr" @click="gotoProductDtl(item.tourId)" v-if="item.orderStatus=='finished'">再来一单</p>
                            <p class="fr" @click="gotoProductDtl(item.tourId)" v-if="item.orderStatus=='canceled'">再来一单</p>
                            <p class="fr" v-if="item.orderStatus=='paid'">联系客服</p>
                            <p class="fr" v-if="item.orderStatus=='unPaid'" @click="gotoDetalDtl(item.id)">立即支付</p>
                        </div>
                </li>
            </ul>
        </div>

    </div>
</template>

<script>
import http from "@/assets/js/axios";
import httpr from "@/assets/js/axiosr";
import { domain } from '@/assets/js/config'
import $ from 'jquery'
import { Toast } from 'mint-ui';
export default {
    data() {
        return {
            isAshow: false,
            userToken: '',
            list: [],
            queryParam: {
                orderStatus: '-1',
                page: 0,
                size: 10
            }
        }
    },
    components: {

    },
    mounted() {
        let userToken = localStorage.getItem("token") || ''
        this.userToken = userToken
        let poctId = this.$route.query.id || '-1';
        this.queryParam.orderStatus = poctId
        // if (!this.userToken) {
        //     this.$router.push('/index')
        // }
        this.tourListNow()
    },
    methods: {
        direct: function (val) {
            this.$router.push({ path: '/' + val });
        },
        tourListNow: async function () {
            const res = await httpr.post('tour_order_search/list_by_page?token=' + this.userToken, this.queryParam)
            // console.log(res);
            if (res.data.code == 100) {
                // Toast({ message: res.data.message, duration: 1000 })
                this.list = res.data.data
            } else {
                Toast({ message: res.data.message, duration: 1000 })
            }
        },
        gotoDetalDtl: function (pid) {
            this.$router.push({ path: '/tourDetails', query: { 'id': pid } })
        },
        gotoProductDtl: function (pid) {
            this.$router.push({ path: '/tourProduct', query: { 'id': pid } })
        }
    }
}
</script>

<style lang="stylus" scoped>
.tour-order {
    .line {
        width: 100%;
        height: 12px;
        background: rgba(240, 240, 240, 1);
    }

    div.tabs {
        width: 100%;
        height: 44px;
        line-height: 44px;

        ul {
            li {
                padding-top: 10px;
                height: 44px;
                line-height: 44px;
                text-align: center;
                width: 25%;
                font-size: 12px;
                font-family: PingFangSC-Regular;
                font-weight: 400;
                color: rgba(51, 51, 51, 1);
                line-height: 24px;
            }

            .active {
                border-bottom: 2px solid #8FC31F;
            }
        }
    }

    .ment {
        width: 100%;
        height: 44px;
        line-height: 44px;
        padding: 0 15px;
        background: rgba(240, 240, 240, 1);
        font-size: 14px;
        font-family: PingFangSC-Regular;
        font-weight: 400;
        color: rgba(0, 0, 0, 1);
    }

    .listm {
        ul {
            li {
                padding: 13px;
                border-bottom: 10px solid rgba(240, 240, 240, 1);

                .top {
                    width: 100%;
                    height: 48px;
                    line-height: 48px;
                    border-bottom: 1px solid rgba(240, 240, 240, 1);

                    .img {
                        width: 48px;
                        height: 48px;

                        img {
                            width: 100%;
                            height: 100%;
                        }
                    }

                    .word {
                        margin-right: 5px;
                        font-size: 12px;
                        font-family: PingFangSC-Regular;
                        font-weight: 400;
                        color: rgba(153, 153, 153, 1);
                    }

                    .words {
                        margin-right: 5px;
                        font-size: 12px;
                        font-family: PingFangSC-Regular;
                        font-weight: 400;
                        color: rgba(153, 153, 153, 1);
                    }

                    .wordt {
                        margin-right: 5px;
                        font-size: 12px;
                        font-family: PingFangSC-Regular;
                        font-weight: 400;
                        color: rgba(85, 194, 2, 1);
                    }

                    .wordm {
                        width: 60px;
                        height: 25px;
                        line-height: 25px;
                        border-radius: 5px;
                        text-align: center;
                        margin-top: 12px;
                        margin-right: 5px;
                        background: rgba(143, 195, 31, 1);
                        font-size: 12px;
                        font-family: PingFangSC-Regular;
                        font-weight: 400;
                        color: #fff;
                    }
                }

                .center {
                    border-bottom: 1px solid rgba(240, 240, 240, 1);
                    margin-top: 10px;
                    padding-bottom: 10px;

                    .title {
                        .tits {
                            width: 280px;
                            font-size: 12px;
                            font-family: PingFangSC-Regular;
                            font-weight: 400;
                            color: rgba(51, 51, 51, 1);
                        }

                        .state {
                            font-size: 14px;
                            font-family: PingFangSC-Regular;
                            font-weight: 400;
                            color: rgba(153, 153, 153, 1);

                            span:nth-child(1) {
                                font-size: 12px;
                            }
                        }
                    }

                    .time {
                        .word {
                            margin-top: 5px;
                            font-size: 12px;
                            font-family: PingFangSC-Regular;
                            font-weight: 400;
                            color: rgba(51, 51, 51, 1);
                        }
                    }
                }

                .fott {
                    margin-top: 10px;

                    p {
                        margin-right: 10px;
                        width: 90px;
                        height: 35px;
                        line-height: 35px;
                        text-align: center;
                        background: rgba(255, 255, 255, 1);
                        border-radius: 5px;
                        border: 1px solid #999;
                        font-size: 14px;
                        font-family: PingFangSC-Regular;
                        font-weight: 400;
                        color: rgba(153, 153, 153, 1);
                    }
                }
            }
        }
    }
}
</style>
